<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
String path = request.getContextPath();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>添加库存</title>
    <link href="<%=path%>/css/core.css" rel="stylesheet" type="text/css"/>
    <link href="<%=path%>/css/form.css" rel="stylesheet" type="text/css"/>
    <link href="<%=path%>/css/list.css" rel="stylesheet" type="text/css"/>
    <link href="<%=path%>/css/xToolbar.css" rel="stylesheet" type="text/css"/>
  </head>
  <body>
    <form name="stockForm" id="stockForm" action="<%=path%>/product/stock/save.t4m" class="form" method="post">
      <div class="form-group">基本信息</div>
      <table class="form-table" cellspacing="0" cellpadding="0">
        <tr>
          <td class="form-left">选择仓库</td>
          <td class="form-right"><s:select name="object.warehouse.id" value="" list="wlist" listKey="id" listValue="name" theme="simple"/></td>
        </tr>
      </table>
      <div id="toolbar"></div>
      <table id="titleTable" cellpadding="0" cellspacing="0">
        <tr>
          <td><input type="checkbox" id="allBox"/></td>
          <td>货品编号</td>
          <td>货品名称</td>
          <td>存放数量</td>
        </tr>
      </table>
      <table id="dataTable" cellpadding="0" cellspacing="0">
        
      </table>
      <s:hidden name="tabId"/>
      <s:hidden name="windowPanelId"/>
    </form>
    <script src="<%=path%>/js/core.js" type="text/javascript"></script>
    <script src="<%=path%>/js/jquery.js" type="text/javascript"></script>
    <script src="<%=path%>/js/share.js" type="text/javascript"></script>
    <script src="<%=path%>/js/Grid.js" type="text/javascript"></script>
    <script src="<%=path%>/js/BoxSelect.js" type="text/javascript"></script>
    <script src="<%=path%>/js/xToolbar.js" type="text/javascript"></script>
    <script src="<%=path%>/js/xToolbar.items.js" type="text/javascript"></script>
    <script src="<%=path%>/js/modules/product/product.js" type="text/javascript"></script>
    <script type="text/javascript">
    var grid;
    function addData(array) {
      var htmlArray = [];
      for(var i = 0; i < array.length; i++) {
        htmlArray.push('<tr class="row">');
        htmlArray.push('<td class="box"><input type="checkbox" name="idListBox"/><input type="hidden" name="idList" value="'+array[i].id+'"/></td>');
        htmlArray.push('<td><span>'+array[i].code+'</span></td>');
        htmlArray.push('<td><span>'+array[i].name+'</span></td>');
        htmlArray.push('<td><input type="text" class="text" name="amounts" style="width:72px;"/></td>');
        htmlArray.push('</tr>');
      }
      $('#dataTable').append(htmlArray.join(''));
      grid.updateAll();
      new BoxSelect({
        allId : 'allBox',
        boxName : 'idListBox'
      });
    }
    
    $(function(){
      var toolbar = new Toolbar({
        id: '1',
        renderTo : 'toolbar',
        icon: '../../image/op.gif',
        border:'both',
        items : [{
          type : 'button',
          text : '添加货品',
          useable : 'T',
          position: {
            a: '0px 0px',
            b: '0px -120px'
          },
          handler : function(){
            productFunctions.choose();
          }
        },'-',{
          type : 'button',
          text : '删除',
          useable : 'T',
          position: {
            a: '-40px 0px',
            b: '-40px -120px'
          },
          handler : function(){
        	  $('tr.selected').remove();
              grid.updateAll();
              new BoxSelect({
                allId : 'allBox',
                boxName : 'idListBox'
              });
          }
        }]
      });
      
      grid = new Grid({
        titleTable:'titleTable',
        dataTable:'dataTable',
        widths : [24,100,150,80],
        height : $(document.body).height() - $('div.form-group').outerHeight() - $('table.form-table').outerHeight() - $('#toolbar').outerHeight()
      });
      
      new BoxSelect({
        allId : 'allBox',
        boxName : 'idListBox'
      });
    });
    </script>
  </body>
</html>